<template>
  <div>
    <div class="sure_content">
      <p class="first_text">手机充值</p>
      <p class="second_text">￥30.00</p>
    </div>
    <div class="hwo_pay1">
      <span>金额</span>
      <span>￥30.00</span>
    </div>
    <div class="hwo_pay">支付方式</div>
    <div class="wx_pay">
      <div class="wx_left">
        <img src="@/assets/images/citizen/wxtitle.png" alt />
        <span>微信支付</span>
        <span class="payimg"></span>
      </div>
      <div class="wx_right">
        <img src="@/assets/images/citizen/ggradio.png" alt />
      </div>
    </div>
    <div class="pay_money" @click="payNow">立即支付</div>
    <img class="bottom" src="@/assets/images/citizen/ysfcode.png" alt />
  </div>
  <!-- coin>=money*100? '0.01' : (money-(coin/100)==0.01? '0.01' : (money-(coin/100) >= 0? money-(coin/100).toFixed(2) : 0.01 -->
</template>
<script>
// import weixin from '@/components/wx/wx.js';
import { Toast, Dialog } from 'vant';
// import wx from 'weixin-js-sdk';
export default {
  data() {
    return { Toast };
  },
  methods: {
    payNow() {
      Dialog.confirm({
        message: `确认支付`,
        confirmButtonText: '立即支付',
        cancelButtonText: '取消'
      })
        .then(() => {
          // 调起支付
          this.$http
            .post('/oneYuanPurchase/submitOrder', {
              type: '3',
              username: this.$route.params.username,
              idCardNo: this.$route.params.idCardNo,
              productName: '话费',
              bankUserId: '',
              phone: this.$route.params.phone ? this.$route.params.phone : ''
            })
            .then(result => {
              console.log(result);
              this.id = JSON.stringify(result.data.object);
              if (result.data.code === '0') {
                this.$http
                  .post('oneYuanPurchase/topay', {
                    orderId: this.id,
                    payType: '1'
                  })
                  .then(res => {
                    console.log(res);
                    if (res.data.code === '0') {
                      window.location.href = res.data.object.wechatPayURL;
                    } else {
                      Toast(res.data.message);
                    }
                    // console.log(this.id);
                  });
              } else {
                Toast(result.data.message);
              }
            });
        })
        .catch(() => {});
    }
  },
  mounted() {}
};
</script>
<style lang="scss" scoped>
.sure_content {
  width: 750px;
  height: 250px;
  background-color: #ffffff;
  box-shadow: 0px 2px 0px 0px rgba(224, 223, 221, 0.52);
  text-align: center;
  padding-top: 68px;
  .first_text {
    font-size: 30px;
    color: #3b3b3b;
  }
  .second_text {
    font-size: 72px;
    color: #010101;
  }
}
.sure_content1 {
  width: 750px;
  height: 300px;
  background-color: #ffffff;
  box-shadow: 0px 2px 0px 0px rgba(224, 223, 221, 0.52);
  text-align: center;
  align-items: center;
  display: flex;
  align-items: center;
  justify-content: center;
  // padding-top: 68px;
  img {
    width: 679px;
    height: 257px;
  }
}
.hwo_pay {
  width: 750px;
  height: 88px;
  background-color: #ffffff;
  box-shadow: 0px -2px 0px 0px rgba(234, 234, 234, 0.35);
  margin-top: 32px;
  line-height: 88px;
  font-size: 30px;
  color: #454545;
  padding-left: 29px;
}
.hwo_pay1 {
  width: 750px;
  height: 88px;
  background-color: #ffffff;
  box-shadow: 0px -2px 0px 0px rgba(234, 234, 234, 0.35);
  margin-top: 32px;
  line-height: 88px;
  font-size: 30px;
  color: #454545;
  padding-left: 29px;
  padding-right: 29px;
  display: flex;
  justify-content: space-between;
  :nth-child(2) {
    color: red;
  }
}
.wx_pay {
  width: 750px;
  height: 88px;
  background-color: #ffffff;
  margin-top: 2px;
  display: flex;
  justify-content: space-between;
  .wx_left {
    display: flex;
    padding-left: 32px;
    line-height: 88px;
    .payimg {
      width: 190px;
      height: 27px;
      align-self: center;
      margin-left: 20px;
      background-image: url(../../../assets/images/citizen/ggthot.png);
      background-size: 100% 100%;
      background-repeat: no-repeat;
    }
    img {
      display: block;
      width: 40px;
      height: 36px;
      line-height: 88px;
      margin-top: 26px;
      margin-right: 20px;
    }
    span {
      font-size: 30px;
      letter-spacing: -1px;
      color: #1c1c1e;
    }
  }
  .wx_right {
    width: 38px;
    height: 38px;
    margin-top: 26px;
    margin-right: 33px;
  }
}
.pay_money {
  width: 690px;
  height: 88px;
  background-color: #59b7f5;
  box-shadow: 0px -2px 0px 0px #e0dfdd;
  border-radius: 8px;
  text-align: center;
  line-height: 88px;
  color: #fafafb;
  font-size: 32px;
  margin: 82px auto;
}
.bottom {
  width: 600px;
  margin-left: 50px;
  padding-bottom: 30px;
}
</style>